package com.jkgh.remedium.objects.messages.ins {
	
	import com.jkgh.logger.Log;
	import com.jkgh.remedium.RemediumSystem;
	import com.jkgh.remedium.objects.RemediumMethodObject;
	import com.jkgh.remedium.objects.messages.RemediumInMessage;
	import com.jkgh.remedium.states.GatheringState;
	import com.jkgh.remedium.tools.RemediumTools;
	
	public class RemediumS2CCaller extends RemediumInMessage {
						
		override public final function consumeContent(remedium:RemediumSystem, onDone:Function):void {
			var thisReference:RemediumInMessage = this;
			remedium.setState(new GatheringState(12, function(remedium:RemediumSystem):void {
				
				var objectID:int = remedium.produceInt();
				var methodID:int = remedium.produceInt();
				var callID:int = remedium.produceInt();
				
				Log.debug("Someone calls: ", objectID, ", ", methodID, ", ", callID);
				
				var methodObject:RemediumMethodObject = remedium.getMethodObject(remedium.getHostID(), objectID);
				methodObject.call(remedium, thisReference, callID, methodID, onDone);
			}));
		}
	}
}